<?php
/**
 * Created by yuxianjun001@icloud.com.
 * User: wuchen
 * Date: 2019/3/20
 * Time: 17:09
 */

namespace App\search\controller;


use Common\controller\Controller;
use \Elasticsearch\ClientBuilder;

/**
 * Elasticsearch 搜索引擎类
 * Class Elasticsearch
 * @package App\search\controller
 */
class Elasticsearch extends Controller
{
    /**
     * 创建索引文档
     */
    public function index(){
       $client= ClientBuilder::create()->build();
        $params = [
            'index' => 'my_index',
            'type' => 'my_type',
            'id' => 'my_id',
            'body' => ['testField' => 'abc']
        ];
        $params2 = [
            'index' => 'my_index',
            'type' => 'my_type',
            'id' => 'my_id',
        ];


        $response = $client->index($params);
       // var_dump($response);
        //$response3=$client->delete($params2);
        //var_dump($response3);die;

        $response2 = $client->get($params2);
        var_dump($response2);

    }

}